﻿<Window x:Class="UpdateBot2.UI.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:updateBotUI="clr-namespace:UpdateBot2.UI"
        Title="UpdateBot" Height="359" Width="772" SizeChanged="Window_SizeChanged" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" ResizeMode="CanResizeWithGrip">
    <Window.Resources>
        <updateBotUI:BoolToVisibilityConverter x:Key="bool2visibleConverter" />
    </Window.Resources>

    <DockPanel>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="266*" />
                <ColumnDefinition Width="247*" />
            </Grid.ColumnDefinitions>
            <DataGrid SelectionUnit="FullRow" AutoGenerateColumns="False" RowBackground="AliceBlue" GridLinesVisibility="None" Name="downloadsGrid" IsReadOnly="True" AlternatingRowBackground="Gainsboro" Margin="0,44,0,29" Grid.ColumnSpan="2">
                <DataGrid.Columns>

                    <DataGridTemplateColumn Header="Download?">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox IsChecked="{Binding Path=IsChecked, UpdateSourceTrigger=PropertyChanged}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTemplateColumn Header="Icon" Width="40" CanUserResize="False">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Canvas Width="37" Height="37">
                                    <Image Width="32" Height="32" Source="{Binding IconURI}"/>
                                    <Image Canvas.Bottom="0" Canvas.Right="0" Width="16" Source="/UpdateBot2.0;component/Images/accept.png" Visibility="{Binding Path=IsDownloadComplete,Converter={StaticResource bool2visibleConverter}}"/>
                                </Canvas>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTextColumn Width="*" Header="Title" Binding="{Binding Title}" />
                    <DataGridTextColumn Width="*" Header="Version" Binding="{Binding Version}" />
                    <DataGridTextColumn Width="*" Header="Publisher" Binding="{Binding Publisher}" />

                    <DataGridTemplateColumn Header="Progress" Width="100">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <ProgressBar Height="30" Value="{Binding Path=DownloadProgress, Mode=OneWay}" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                </DataGrid.Columns>

                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="BorderThickness" Value="0"/>
                        <Setter Property="Padding" Value="4" />

                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type DataGridCell}">
                                    <Border Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <!---This centers content!-->
                    </Style>
                </DataGrid.CellStyle>
            </DataGrid>

            <Canvas Name="progressCanvas" Margin="0,22,0,0" Visibility="Hidden" Grid.ColumnSpan="2">
                <Border Name="loadingPanel" CornerRadius="6" BorderBrush="Gray" Background="LightGray" BorderThickness="2" DockPanel.Dock="Top">
                    <StackPanel Margin="5" Canvas.Left="147" Canvas.Top="79" Height="Auto" Width="200">
                        <ProgressBar Name="loadingProgressBar" Value="0" Margin="5,0,0,0" Width="180" Height="30" IsIndeterminate="True" Maximum="50" />
                        <Label Content="Loading Download Information..." Name="label1" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" />
                    </StackPanel>
                </Border>
            </Canvas>
            <ToolBar Height="40" Name="toolBar1" VerticalAlignment="Top" Grid.ColumnSpan="2">

                <Button Name="StartDownloadButton" Cursor="Hand" Click="Button_Click" ToolTip="Start Download">
                    <Image Source="/UpdateBot2.0;component/Images/box_down.png"/>
                </Button>

                <Button Name="ScanUpdatePageButton" Cursor="Hand" ToolTip="Scan Update Checker Page" Click="ScanUpdatePageButton_Click">
                    <Image Source="/UpdateBot2.0;component/Images/scanner.png"/>
                </Button>

                <Separator></Separator>

                <Button Visibility="Collapsed" Name="SettingsButton" Cursor="Hand" ToolTip="Settings">
                    <Image Source="/UpdateBot2.0;component/Images/setting_tools.png"/>
                </Button>

                <Button Name="CheckAllButton" Cursor="Hand" ToolTip="Check All Downloads" Click="CheckAllButton_Click">
                    <Image Source="/UpdateBot2.0;component/Images/check_box.png"/>
                </Button>
                
                <Button Name="UnCheckAllButton" Cursor="Hand" ToolTip="Uncheck All Downloads" Click="UnCheckAllButton_Click">
                    <Image Source="/UpdateBot2.0;component/Images/cross.png"/>
                </Button>

            </ToolBar>
            <StatusBar Name="statusBar1" Height="23" VerticalAlignment="Bottom" Grid.ColumnSpan="2">
                <TextBlock Name="StatusLabel"  Text="Idle"></TextBlock>
                <TextBlock Visibility="Collapsed" Name="DownloadProgress" Text="0%" Margin="20,0,0,0"></TextBlock>
                <TextBlock Visibility="Collapsed" Name="DownloadRateLabel" Text="0kbs" Margin="20,0,0,0"></TextBlock>
            </StatusBar>
        </Grid>
    </DockPanel>
</Window>
